/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function joinGroupPlan(userid, groupplanid) {
    //alert("fasdasd");
    Ext.Msg.confirm("Confirm","You want to join this group plan?", function(btn) {
        if(btn == 'yes') {
            join(userid, groupplanid);
        }
    });
}

function join(userid, groupplanid) {
    Ext.Ajax.request({
        url:'space.do?action=joinGroupPlan',
        method:'post',
        params:{
            userid : userid,
            groupplanid : groupplanid
        },
        success:function(response){
            var responseArray = Ext.util.JSON.decode(response.responseText);
            if(responseArray.success==true){
                Ext.Msg.alert('Information','Join group plan success!', function(){
                    window.location.href="PersonalSpace.jsp?userid="+userid;
                });
            }
            else{
                Ext.Msg.alert('Information','Join group plan failed!');
            }
        },

        failure:function(action){
            alert('failed');
            Ext.Msg.alert('Error', 'Reason\uff1a' + action.result.errors.info);
        }
    });
}


